import { OutputChannel, window } from 'vscode';
import { LocalizeConst } from '../../constants';
import { localize } from '../../localize';

/**
 * 日志输出
 *
 * @author chitanda
 * @date 2022-01-18 12:01:44
 * @export
 * @class Log
 */
export class Log {
  /**
   * 日志输出面板
   *
   * @author chitanda
   * @date 2022-01-18 12:01:50
   * @protected
   * @static
   */
  protected channel?: OutputChannel;

  info(message: string): void {
    this.output(message);
  }

  protected output(message: string): void {
    if (!this.channel) {
      this.channel = window.createOutputChannel(localize(LocalizeConst.PLUGIN_NAME, 'iBizlab Handlebars Preview'));
    }
    this.channel.appendLine(message);
  }
}

export const log = new Log();
